<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="/Home/css/style.css" />
    <!--[if IE 6]>
    <script src="/Home/js/iepng.js" type="text/javascript"></script>
        <script type="text/javascript">
           EvPNG.fix('div, ul, img, li, input, a'); 
        </script>
    <![endif]-->
    
    <script type="text/javascript" src="/Home/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="/Home/js/menu.js"></script>    
                
	<script type="text/javascript" src="/Home/js/n_nav.js"></script>   
    
    <script type="text/javascript" src="/Home/js/num.js">
    	var jq = jQuery.noConflict();
    </script>     
    
    <script type="text/javascript" src="/Home/js/shade.js"></script>
    
<title>NBshop</title>
</head>
<body>  
<!--Begin Header Begin-->
@include('Home.parent')
<div class="top">
    <div class="logo"><a href="index"><img src="/Home/images/nb.png" / width="150px" height="55px"></a></div>
    <div class="search">
    	<form>
        	<input type="text" value="" class="s_ipt" />
            <input type="submit" value="搜索" class="s_btn" />
        </form>                      
        <span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a href="#">新鲜美食</a><a href="#">蛋糕</a><a href="#">日用品</a><a href="#">连衣裙</a></span>
    </div>
    <div class="i_car">
    	<div class="car_t">购物车 [ <span>3</span> ]</div>
        <div class="car_bg">
       		<!--Begin 购物车未登录 Begin-->
        	<div class="un_login">还未登录！<a href="login" style="color:#ff4e00;">马上登录</a> 查看购物车！</div>
            <!--End 购物车未登录 End-->
            <!--Begin 购物车已登录 Begin-->
            <ul class="cars">
            	<li>
                	<div class="img"><a href="#"><img src="/Home/images/car1.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">法颂浪漫梦境50ML 香水女士持久清新淡香 送2ML小样3只</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
                <li>
                	<div class="img"><a href="#"><img src="/Home/images/car2.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
                <li>
                	<div class="img"><a href="#"><img src="/Home/images/car2.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
            </ul>
            <div class="price_sum">共计&nbsp; <font color="#ff4e00">￥</font><span>1058</span></div>
            <div class="price_a"><a href="#">去购物车结算</a></div>
            <!--End 购物车已登录 End-->
        </div>
    </div>
</div>
<!--End Header End--> 
<!--Begin Menu Begin-->
<div class="menu_bg">
    <div class="menu">
        @include('Home.menu')
    </div>
</div>
<!--End Menu End--> 
<div class="i_bg">  
    <div class="content mar_20">
    	<img src="/Home/images/img1.jpg" />        
    </div>
    
    <!--Begin 第一步：查看购物车 Begin -->
    <div class="content mar_20">
    	<table border="0" class="car_tab" style="width:1200px; margin-bottom:50px;" cellspacing="0" cellpadding="0">
          <tr>
            <td class="car_th" width="490">商品名称</td>
            <td class="car_th" width="140">属性</td>
            <td class="car_th" width="150">购买数量</td>
            <td class="car_th" width="130">当前单价</td>
            <td class="car_th" width="140">当前原价</td>
            <td class="car_th" width="150">操作</td>
          </tr>
         <?php foreach ($res as $key => $value) {?>   
          <tr class="car_tr" data-id="<?=$value['goods_id']?>" data-cartid="<?=$value['cart_id']?>" data-attr="<?=$value['product_attr_id']?>">
            <td>
            	<div class="c_s_img"><img src="<?=$value['goods_img']?>" width="73" height="73" /></div>
                <?=$value['goods_name']?>
            </td>
            <td align="center"><?=$value['product_attr_value']?></td>
            <td align="center">
            	<div class="c_num">
                    <input type="button" value=""  class="car_btn_1" />
                	<input type="text" value="<?=$value['buy_num']?>" name="buy_num" disabled class="car_ipt" />  
                    <input type="button" value=""  class="car_btn_2" />
                </div>
            </td>
            <td align="center" style="color:#ff4e00;">￥<?=$value['goods_price_one']?></td>
            <td align="center"><?=$value['goods_price']?></td>
            <td align="center"><a href="/home/cartdel/<?=$value['cart_id']?>">删除</a>&nbsp; &nbsp;<a href="/home/addcollect/<?=$value['goods_id']?>">加入收藏</a></td>
          </tr>
          <?php } ?>
          <tr height="70">
          	<td colspan="6" style="font-family:'Microsoft YaHei'; border-bottom:0;">
            	<label class="r_rad"><input type="checkbox" name="clear" checked="checked" /></label><label class="r_txt">清空购物车</label>
                <span class="fr">商品总价：<b style="font-size:22px; color:#ff4e00;">￥<span class="price_sums"><?=$sum?></span> </b></span>
            </td>
          </tr>
          <tr valign="top" height="150">
          	<td colspan="6" align="right">
            	<a href="#"><img src="/Home/images/buy1.gif" /></a>&nbsp; &nbsp; <a href="confirm"><img src="/Home/images/buy2.gif" /></a>
            </td>
          </tr>
        </table>
        
    </div>
	<!--End 第一步：查看购物车 End--> 
    
    
    <!--Begin 弹出层-删除商品 Begin-->
    <div id="fade" class="black_overlay"></div>
    <div id="MyDiv" class="white_content">             
        <div class="white_d">
            <div class="notice_t">
                <span class="fr" style="margin-top:10px; cursor:pointer;" onclick="CloseDiv('MyDiv','fade')"><img src="/Home/images/close.gif" /></span>
            </div>
            <div class="notice_c">
           		
                <table border="0" align="center" style="font-size:16px;" cellspacing="0" cellpadding="0">
                  <tr valign="top">
                    <td>您确定要把该商品移除购物车吗？</td>
                  </tr>
                  <tr height="50" valign="bottom">
                    <td><a href="#" class="b_sure">确定</a><a href="#" class="b_buy">取消</a></td>
                  </tr>
                </table>
                    
            </div>
        </div>
    </div>    
    <!--End 弹出层-删除商品 End-->
    
    
    <!--Begin Footer Begin -->
    <div class="b_btm_bg bg_color">
        <div class="b_btm">
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/Home/images/b1.png" width="62" height="62" /></td>
                <td><h2>正品保障</h2>正品行货  放心购买</td>
              </tr>
            </table>
			<table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/Home/images/b2.png" width="62" height="62" /></td>
                <td><h2>满38包邮</h2>满38包邮 免运费</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/Home/images/b3.png" width="62" height="62" /></td>
                <td><h2>天天低价</h2>天天低价 畅选无忧</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="/Home/images/b4.png" width="62" height="62" /></td>
                <td><h2>准时送达</h2>收货时间由你做主</td>
              </tr>
            </table>
        </div>
    </div>
            <!-- 友情链接 -->
@include('Home.foot')
</div>

</body>
</html>
    <script type="text/javascript" src="/Home/js/jquery-1.8.2.min.js"></script>
<script>
$('.car_btn_2').on('click',function(){
    var obj=$(this);
    var c = $(this).parent().find(".car_ipt").val();
    c = parseInt(c)+1; 
    updateNumber(obj,c);
})

$('.car_btn_1').on('click',function(){
    var c = $(this).parent().find(".car_ipt").val();
    var obj=$(this);
    if(c==1){    
        c=1;    
    }else{    
        c=parseInt(c)-1;    
        updateNumber(obj,c);
    }
})
 
 function updateNumber(obj,c){
     var goods_id = obj.parents('tr').data('id');
    var attr_id = obj.parents('tr').data('attr');
    var cart_id = obj.parents('tr').data('cartid');
    $.ajax({
        url:'checkNumber/'+goods_id+'/cart_id/'+cart_id+'/buy_number/'+c+'/product_attr/'+attr_id,
        type:'get',
        dataType:'json',
        success:function(res){
            // alert(res);
            if(res==-1){
                alert('库存不够了');
            }else{
                obj.parent().find(".car_ipt").val(c);
                $('.price_sums').html(res);
            }
            
        }
    });
 }
</script>
<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
